#!/bin/sh

if [ $# -ne 3 ]; then
	echo "Usage: $0 mdfile titlefile numberof#"
	exit -1
fi

mdfile=$1

titlefile=$2

sed -e '/^$/d' $mdfile | awk '{print $0 "\n"}' >$mdfile.1

sed -e "s/^$3 //g" $mdfile.1 | sed -e "s/ $//g">$mdfile


while IFS= read -r line; 
do

	sed -e "s/^$line$/$3 $line/" $mdfile >$mdfile.1
	mv $mdfile.1 $mdfile

done < $titlefile

sed -e "s/\"/“/g" $mdfile  | sed -e "s/\[/\\[/g" | sed -e "s/\]/\\]/g" >$mdfile.1

mv $mdfile.1 $mdfile

echo "please check " $mdfile

grep "^$3 " $mdfile
